package com.example.testanimation.graphics.shared;

import android.app.Activity;
import android.content.Context;
import android.graphics.*;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import com.scenic.rd_android.R;

/**
 * Created by scenic on 2015/3/29.
 */
public class TestShared extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_shared);
    }

    public static class BitmapShaderView extends View{
        private Bitmap mBitmapSrc = null;
        private BitmapShader mBitmapShared;

        public BitmapShaderView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
            mBitmapSrc = BitmapFactory.decodeResource(getResources(),R.mipmap.png_test);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            mBitmapShared = new BitmapShader(mBitmapSrc, Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
            Paint paint =new Paint();
            paint.setShader(mBitmapShared);

            canvas.drawCircle(300, 200, 150, paint);
        }
    }
}